
/*code demos*/

**keep latinos

gen latino=0
recode latino(0=1) if Q1==3
drop if latino==0
tab latino

**age

gen age=Q5
recode age(1=18)(2=19)(3=20)(4=21)(5=22)(6=23)(7=24)(8=25)(9=26)(10=27)(11=28)(12=29)(13=30)(14=31)(15=32)(16=33)(17=34)(18=35)(19=36)(20=37)(21=38)(22=39)(23=40)(24=41)(25=42)(26=43)(27=44)(28=45)(29=46)(30=47)(31=48)(32=49)(33=50)(34=51)(35=52)(36=53)(37=54)(38=55)(39=56)(40=57)(41=58)(42=59)(43=60)(44=61)(45=62)(46=63)(47=64)(48=65)(49=66)(50=67)(51=68)(52=69)(53=70)(54=71)(55=72)(56=73)(57=74)(58=75)(59=76)(60=77)(61=78)
summ age
summ age, detail

**gender

gen female=0
recode female(0=1) if Q6==1 
tab female

**ideology

gen liberal1=Q8
summ liberal1
gen liberal=(liberal1-1)/6
summ liberal


/*experiment*/

**treatments

encode m1, gen(treats)

gen inferior=0
recode inferior(0=1) if treats==2

gen american=0
recode american(0=1) if treats==3

tab inferior american
tab inferior
tab american


/*results for SI.2*/

**randomization check

reg inferior age female liberal if american==0
test age female liberal

**balance check

ttest age if american==0, by(inferior)
ttest female if american==0, by(inferior)
ttest liberal1 if american==0, by(inferior)

reg inferior age female liberal if american==0
test age female liberal


***************************************************************
******to analyze with failed manipulation checks included******
******do not run next nine lines of code**********************
***************************************************************

gen check=0

**control manipulation check

recode check(0=1) if Q14==2

**inferior manipulation check

recode check(0=1) if Q15==2

**american manipulation check

recode check(0=1) if Q16==2


/*characteristics of failed manipulation checks*/

tab check if american==0

ttest age if american==0, by(check)
ttest female if american==0, by(check)
ttest liberal if american==0, by(check)

drop if check==1


/*N=1303 - dropped N = analyzed sample...restrict to inferiority treatment*/

tab american


/*reassess balance after dropping failed manipulation checks*/

reg inferior age female liberal if american==0
test age female liberal

ttest age if american==0, by(inferior)
ttest female if american==0, by(inferior)
ttest liberal if american==0, by(inferior)


/*mediator - solidarity with poc*/

gen poc1=Q17
summ poc1

gen poc2=Q18
recode poc2(1=5)(2=4)(3=3)(4=2)(5=1)
summ poc2

alpha poc1 poc2
pwcorr poc1 poc2, sig

gen pocsolid1=(poc1+poc2)/2
summ pocsolid1

gen pocsolid=(pocsolid1-1)/4
summ pocsolid


/*outcomes*/

gen borderpat1=Q19
recode borderpat1(1=5)(2=4)(3=3)(4=2)(5=1)
summ borderpat1

gen daca1=Q20
summ daca1

gen pathway1=Q21
summ pathway1

alpha borderpat1 daca1 pathway1, std
pwcorr borderpat1 daca1 pathway1, sig


gen hatecrime1=Q22
summ hatecrime1

gen blm1=Q23
recode blm1(1=5)(2=4)(3=3)(4=2)(5=1)
summ blm1

gen repar1=Q23
summ repar1

***recode variables to 0-1 range

gen hatecrime=(hatecrime1-1)/4
gen blm=(blm1-1)/4
gen repar=(repar1-1)/4

gen borderpat=(borderpat1-1)/4
gen daca=(daca1-1)/4
gen pathway=(pathway1-1)/4

summ hatecrime blm repar borderpat daca pathway

**create policy scales

gen prolat=(borderpat+daca+pathway)/3
summ prolat

gen problk=(blm+hatecrime)/2
summ problk


/*mediation analysis*/

**basic (baron and kenny)

reg pocsolid inferior if american==0
ttest pocsolid if american==0, by(inferior)

reg hatecrime pocsolid if american==0
reg blm pocsolid if american==0
reg repar pocsolid if american==0
reg problk pocsolid if american==0

reg problk inferior if american==0

reg borderpat pocsolid if american==0
reg daca pocsolid if american==0
reg pathway pocsolid if american==0
reg prolat pocsolid if american==0

**robust to ideology

reg hatecrime pocsolid liberal
reg blm pocsolid liberal
reg repar pocsolid liberal
reg borderpat pocsolid liberal
reg daca pocsolid liberal
reg pathway pocsolid liberal


/*SI.5, results robust to inclusion of both experimental conditions*/

reg pocsolid inferior american
reg problk inferior american


/*generate comparison of inferiority treatment to conrol only*/

gen inferior2=.
recode inferior2(.=1) if inferior==1
recode inferior2(.=0) if treats==1
tab inferior2

ttest pocsolid, by(inferior2)
ttest problk, by(inferior2)


/*SI.2, does gender moderate the treatment?*/

gen feminferior=(female*inferior2)

reg pocsolid inferior2 female

reg pocsolid inferior2 female feminferior, robust
test female feminferior


/*Table 2, results with liberal ideology as covariate in downstream path*/

medeff (regress pocsolid inferior2) (regress borderpat inferior2 pocsolid liberal), mediate(pocsolid) treat(inferior2) sims(1000) seed(1)
medeff (regress pocsolid inferior2) (regress daca inferior2 pocsolid liberal), mediate(pocsolid) treat(inferior2) sims(1000) seed(1)
medeff (regress pocsolid inferior2) (regress pathway inferior2 pocsolid liberal), mediate(pocsolid) treat(inferior2) sims(1000) seed(1)
medeff (regress pocsolid inferior2) (regress prolat inferior2 pocsolid liberal), mediate(pocsolid) treat(inferior2) sims(1000) seed(1)

medeff (regress pocsolid inferior2) (regress hatecrime inferior2 pocsolid liberal), mediate(pocsolid) treat(inferior2) sims(1000) seed(1)
medeff (regress pocsolid inferior2) (regress blm inferior2 pocsolid liberal), mediate(pocsolid) treat(inferior2) sims(1000) seed(1)
medeff (regress pocsolid inferior2) (regress problk inferior2 pocsolid liberal), mediate(pocsolid) treat(inferior2) sims(1000) seed(1) level(93)

**sensitivity analysis

medsens (regress pocsolid inferior2) (regress problk inferior2 pocsolid liberal), mediate(pocsolid) treat(inferior2) sims(1000)

**without liberal ideology as covariate in downstream path

medeff (regress pocsolid inferior2) (regress borderpat inferior2 pocsolid), mediate(pocsolid) treat(inferior2) sims(1000) seed(1)
medeff (regress pocsolid inferior2) (regress pathway inferior2 pocsolid), mediate(pocsolid) treat(inferior2) sims(1000) seed(1)
medeff (regress pocsolid inferior2) (regress daca inferior2 pocsolid), mediate(pocsolid) treat(inferior2) sims(1000) seed(1)
medeff (regress pocsolid inferior2) (regress prolat inferior2 pocsolid), mediate(pocsolid) treat(inferior2) sims(1000) seed(1)

medeff (regress pocsolid inferior2) (regress hatecrime inferior2 pocsolid), mediate(pocsolid) treat(inferior2) sims(1000) seed(1)
medeff (regress pocsolid inferior2) (regress blm inferior2 pocsolid), mediate(pocsolid) treat(inferior2) sims(1000) seed(1)
medeff (regress pocsolid inferior2) (regress problk inferior2 pocsolid), mediate(pocsolid) treat(inferior2) sims(1000) seed(1)


/*results for SI.7*/

**with only first solidarity item as mediator

gen poc11=(poc1-1)/4
summ poc11

medeff (regress poc11 inferior2) (regress problk inferior2 poc11 liberal), mediate(poc11) treat(inferior2) sims(1000) seed(1) level(90)
medeff (regress poc11 inferior2) (regress prolat inferior2 poc11 liberal), mediate(poc11) treat(inferior2) sims(1000) seed(1) level(90)

**with only second solidarity item as mediator

gen poc22=(poc2-1)/4
summ poc22

medeff (regress poc22 inferior2) (regress problk inferior2 poc22 liberal), mediate(poc22) treat(inferior2) sims(1000) seed(1) level(90)
medeff (regress poc22 inferior2) (regress prolat inferior2 poc22 liberal), mediate(poc22) treat(inferior2) sims(1000) seed(1) level(80)
